<template>
  <div class="loginRegister">
    <div class="loginRegisterFrom-box">
      <div class="zh-en" @click="changeLanguage">
        {{$t("loginRegistration.title.languageChange")}}
      </div>
      <div class="formTitle">
        <span>{{$t("loginRegistration.title.pageTitle")}}</span>
      </div>
      <router-view @component="routerView"></router-view>
      <footer>
        <router-link to="/loginRegistrationPage/retrievePassword">
          <button v-if="this.component == 'login'" type="button" class="forgotBtn" style="display: block" >
            {{$t("loginRegistration.title.findPassword")}}
          </button>
          <button v-else type="button" class="forgotBtn" style="display: none" >
            {{$t("loginRegistration.title.findPassword")}}
          </button>
        </router-link>
        <router-link to="/loginRegistrationPage/login">
          <button v-if="this.component != 'login'" type="button" class="returnBtn" style="display: block" >{{$t("loginRegistration.title.return")}}</button>
          <button v-else type="button" class="returnBtn" style="display: none" >
            {{$t("loginRegistration.title.return")}}
          </button>
        </router-link>
        <router-link to="/loginRegistrationPage/registration">
          <button v-if="this.component == 'login'" type="button" class="registerBtn" style="display: block" >{{$t("loginRegistration.title.registration")}}</button>
          <button v-else type="button" class="registerBtn" style="display: none" >
            {{$t("loginRegistration.title.registration")}}
          </button>
        </router-link>
      </footer>
    </div>
  </div>
</template>

<script>
    export default {
        name: "LoginRegistrationPage",
        data(){
            return{
                component:'',
                dialogVisible: false
            }
        },
        methods:{
            changeLanguage() {
                if (window.localStorage.getItem("brinkIdea_language") === "zh"){
                    this.en()
                } else {
                    this.zh()
                }
            },
            zh(){
                this.$i18n.locale = "zh"
                window.localStorage.setItem("brinkIdea_language", "zh")
            },
            en(){
                this.$i18n.locale = "en"
                window.localStorage.setItem("brinkIdea_language", "en")
            },
            routerView(val){
                this.component = val
            },
        }
    }
</script>

<style scoped>
  .loginRegister{
    background: url('../../../assets/images/common/login-bg.png') no-repeat center 100%;
    background-size: 100% 100%;
    height: 100vh
  }
  .loginRegisterFrom-box{
    position: relative;
    width: 550px;
    padding: 30px 40px;
    overflow: hidden;
    background-color: #fdfdfda6;
    /* box-shadow: 0 0 20px rgb(180, 180, 180); */
    box-shadow: 0 0 10px rgba(166, 166, 166, 0.9);
    border-radius: 3px;
    letter-spacing: .5px;
    z-index: 999;
    transform-origin:center;

    /* 绝对定位 */
    position:absolute;
    /* 水平居中 */
    left:50%;
    /* 垂直居中  */
    top:50%   ;
    /* 内容相对父元素水平垂直居中 */
    -webkit-transform:translate(-50%,-50%);
    /* 内容相对父元素水平垂直居中 */
    -moz-transform:translate(-50%,-50%);
    /* 内容相对父元素水平垂直居中 */
    transform:translate(-50%,-50%);
  }
  .zh-en{
    width: 10%;
    margin-left: 500px;
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    color: #868b86;
    font-weight: bolder;
  }
  .zh-en:hover{
    color: #399b9c;
  }
  .formTitle{
    width: 100%;
    height: 50px;
    line-height: 20px;
    text-align: center;
    font-size: 18px;
    color: rgb(83, 83, 83);
    font-weight: bold;
    letter-spacing: 0.5px;
    position: relative;
  }
  .closeFrom{
    display: block;
    position: fixed;
    top: 15px;
    right: 40px;
    font-size: 15px;
    color: #000000;
    opacity: 0.5;
  }
  .closeFrom:hover{
    opacity: 1;
  }

  .loginRegisterFrom-box footer {
    margin-top: 15px;
    display: flex;
  }

  .loginRegisterFrom-box footer button {
    background: transparent;
    padding: 0;
    border: 0;
    color: rgb(58, 58, 58);
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    flex: 1;
    opacity: .5;
    position: absolute;
  }
  .forgotBtn{
    left: 40px;
  }
  .returnBtn{
    left: 300px;
    display: none;
  }
  .registerBtn{
    right: 40px;
  }
  .loginRegisterFrom-box footer button:hover {
    opacity: 1;
  }
</style>
